﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ServiceStack.Redis.Support;

namespace SpiderServer
{
	public class MessageSet<T>
	{
		private string name;
		private ObjectSerializer serializer = new ObjectSerializer();
		public MessageSet(string name)
		{
			this.name = name;
			
		}

		public void Add(T item)
		{
			using (var redisClent = Global.GetRedisClient())
			{
				redisClent.SAdd(name, serializer.Serialize(item));
			}
		}

		public bool IsMember(T item)
		{
			using (var redisClent = Global.GetRedisClient())
			{
				return redisClent.SIsMember(name, serializer.Serialize(item)) == 1;
			}
		}

		public void Remove(T item)
		{
			using (var redisClent = Global.GetRedisClient())
			{
				redisClent.SRem(name, serializer.Serialize(item));
			}
		}

	}
}
